<!--

    Copyright (c) 2015-2018 Red Hat, Inc.
    This program and the accompanying materials are made
    available under the terms of the Eclipse Public License 2.0
    which is available at https://www.eclipse.org/legal/epl-2.0/

    SPDX-License-Identifier: EPL-2.0

    Contributors:
      Red Hat, Inc. - initial API and implementation

-->
<che-toolbar che-title="Workspaces" border-none></che-toolbar>
<che-description che-link-title="Learn more." che-link="{{branding.docs.workspace}}">A workspace is where your projects live and run. Create workspaces from stacks that define projects, runtimes, and commands.</che-description>
<md-content md-scroll-y flex layout="column" md-theme="maincontent-theme">
  <md-progress-linear md-mode="indeterminate" class="progress-line"
                      ng-show="listWorkspacesCtrl.isInfoLoading || listWorkspacesCtrl.isRequestPending"></md-progress-linear>
  <md-content flex class="workspace-list-content" ng-hide="listWorkspacesCtrl.isInfoLoading">
    <che-list-header che-input-placeholder="Search"
                     che-search-model="listWorkspacesCtrl.workspaceFilter.config.name"
                     che-on-search-change="listWorkspacesCtrl.onSearchChanged(str)"
                     che-hide-search="listWorkspacesCtrl.userWorkspaces.length === 0"
                     che-add-button-title="Add Workspace"
                     che-add-button-href="{{listWorkspacesCtrl.workspaceCreationLink}}"
                     che-delete-button-title="Delete"
                     che-on-delete="listWorkspacesCtrl.deleteSelectedWorkspaces()"
                     che-filter-values="listWorkspacesCtrl.namespaceLabels"
                     che-on-filter-changed="listWorkspacesCtrl.onFilterChanged"
                     che-hide-delete="listWorkspacesCtrl.cheListHelper.isNoItemSelected"
                     che-hide-header="listWorkspacesCtrl.cheListHelper.visibleItemsNumber === 0">
      <div flex="100"
           layout="row"
           layout-align="start stretch"
           class="che-list-item-row">
        <div layout="column" layout-gt-xs="row"
             layout-align="start center"
             class="che-checkbox-area">
          <div layout="row" layout-align="center center" class="che-list-item-checkbox-main">
            <md-checkbox class="che-list-item-checkbox"
                         aria-label="Workspace list"
                         ng-checked="listWorkspacesCtrl.cheListHelper.areAllItemsSelected === true"
                         ng-click="listWorkspacesCtrl.cheListHelper.changeBulkSelection()"></md-checkbox>
          </div>
        </div>
        <div flex hide-xs layout-gt-xs="row"
             layout-align="start center"
             class="che-list-item-details">
          <che-list-header-column flex-gt-xs="25"
                                  che-sort-value="listWorkspacesCtrl.workspaceOrderBy"
                                  che-sort-item="config.name"
                                  che-column-title="Name"></che-list-header-column>
          <che-list-header-column flex-gt-xs="15"
                                  che-sort-value="listWorkspacesCtrl.workspaceOrderBy"
                                  che-sort-item="config.environments[0].machineConfigs[0].limits.ram"
                                  che-column-title="RAM"></che-list-header-column>
          <che-list-header-column flex-gt-xs="15"
                                  che-sort-value="listWorkspacesCtrl.workspaceOrderBy"
                                  che-sort-item="config.projects"
                                  che-column-title="Projects"></che-list-header-column>
          <che-list-header-column flex-gt-xs="30"
                                  che-sort-value="listWorkspacesCtrl.workspaceOrderBy"
                                  che-sort-item="attributes.stackId"
                                  che-column-title="Stack"></che-list-header-column>
          <che-list-header-column flex-gt-xs="15"
                                  che-column-title="Actions"></che-list-header-column>
        </div>
      </div>
    </che-list-header>
    <che-list ng-show="listWorkspacesCtrl.cheListHelper.visibleItemsNumber > 0">
      <che-workspace-item
              ng-repeat="workspace in listWorkspacesCtrl.cheListHelper.getVisibleItems() | orderBy:[listWorkspacesCtrl.workspaceOrderBy, 'config.name']"
              ng-model="listWorkspacesCtrl.cheListHelper.itemsSelectionStatus[workspace.id]"
              is-request-pending="listWorkspacesCtrl.isRequestPending"
              che-selectable="true"
              che-display-labels="false"
              che-on-checkbox-click="listWorkspacesCtrl.cheListHelper.updateBulkSelectionStatus()"
              che-workspace-item="workspace"></che-workspace-item>
    </che-list>
    <div class="che-list-empty">
        <span ng-show="listWorkspacesCtrl.userWorkspaces.length > 0 && listWorkspacesCtrl.cheListHelper.visibleItemsNumber === 0">
          No workspaces found.
        </span>
      <span ng-show="listWorkspacesCtrl.userWorkspaces.length === 0">There are no workspaces.</span>
    </div>
  </md-content>
</md-content>
